<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath() + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=path%>" />
    <meta charset="UTF-8">
    <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
    <link href="admin/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <!-- <link href="admin/css/font-awesome.min.css" rel="stylesheet" type="text/css"> -->
    <link href="admin/css/style.css" rel="stylesheet" type="text/css">
    <title>管理员登录</title>
</head>
<body>
<div class="container">
    <form class="login-form" id="form" method="post">
        <h2 class="text-center">登录管理系统</h2>
        <div class="login-wrap">
            <!-- icon_lock_alt -->
            <p class="login-img"><i class="icon_lock_alt"></i></p>
            <div class="input-group">
                <span class="input-group-addon"><i class="ace-icon fa fa-user"></i></span>
                <input type="text" name="name" class="form-control" placeholder="用户名" autofocus required>
            </div>
            <div class="input-group" style="font-size:100px!important;">
                <span class="input-group-addon"><i class="ace-icon fa fa-lock"></i></span>
                <input type="password" name="password" class="form-control" placeholder="密码" autofocus required>
            </div>
            <label class="checkbox" style="margin-left: 20px">
               <!--  <input type="checkbox" value="remember-me">记住我
                <span class="pull-right"> <a href="#">忘记密码</a></span> -->
            </label>
        </div>
            <button  onclick="login()" class="btn btn-primary btn-lg btn-block" type="button">登录</button>
    </form>
</div>
	
	<script type="text/javascript">
		function login(){
			var formData = new FormData($("#form")[0]); //用form 表单直接 构造formData 对象; 就不需要下面的append 方法来为表单进行赋值了。 
			$.ajax({
				url : 'admin/login',
				type : 'POST',
				async : true,
				data : formData,
				dataType : 'json',
				contentType : false, //必须false才会自动加上正确的Content-Type 
				processData : false, //必须false才会避开jQuery对 formdata 的默认处理   	
				success : function(data) {
					if (data.code==200) {
						alert("登录成功");
						window.location.href="/Crowdfunding/admin/to/index";
					} else {
						alert(data.msg);
					}
				},
				error : function(msg) {
					alert("网络异常,发布失败");
				}
			});

		}
	</script>

</body>
</html>